package org.mokusakura.service;


import org.mokusakura.domain.Cart;
import org.mokusakura.domain.Order;
import org.mokusakura.domain.User;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

public interface UserService {

    /**
     * @param email    email
     * @param password password
     * @return User with null password if success. return null if not exits email or password is wrong
     * @author MokuSakura
     */
    User login(String email, String password);

    /**
     * @param user     not null
     * @param password not null
     * @return true when equals.
     */
    boolean isRightPassword(User user, String password);

    /**
     * @param user user to register
     * @return user with full fields if success. return null if email already exits
     * @throws Exception - 为止错误
     */
    User register(User user) throws Exception;

    /**
     * <p>发送登录邮件</p>
     *
     * @param email-email
     * @return 1或0
     */
    Integer sendVerificationEmail(String email);

    User update(User user) throws Exception;

    Integer addItemToCart(User user, String itemId) throws Exception;

    Integer updateCartItemQuantity(User user, String itemId, Integer quantity) throws Exception;

    Integer deleteItem(User user, String itemId) throws Exception;

    List<Order> getOrderList(User user);

    Order getOrderByOrderId(Long orderId);

    User getUserByEmail(String email);

    //I don't fell right here
    //Does these three match MVC?
    //By the way the fields of Order are too much!!!
    @Deprecated
    Boolean purchaseStepOne(HttpServletRequest req);

    @Deprecated
    Boolean purchaseStepTwo(HttpServletRequest req, boolean pattern);

    @Deprecated
    Integer purchaseStepThree(HttpServletRequest req);

    Cart getUserCart(User user);

    /**
     * <p>使用邮箱验证码进行登录</p>
     *
     * @param email-登录邮箱
     * @param verifyCode-验证码
     * @return 登陆成功返回user，失败返回null
     */
    User loginWithVerifyCode(String email, String verifyCode);

    /**
     * <p>发送短信</p>
     *
     * @param phoneNumber-手机号
     * @return 发送成功返回true，失败返回false
     */
    Boolean sendText(String phoneNumber);

    /**
     * <p>使用手机验证码进行登录</p>
     *
     * @param phoneNumber-要登录的手机号
     * @param phoneVerifyCode-手机验证码
     * @return 成功返回user，失败返回null
     */
    User loginWithPhoneVerifyCode(String phoneNumber, String phoneVerifyCode);
}
